import { regionDetail } from "../../../api/index"
import { resetHtml } from "../../../utils/util"

// pages/area/areaDetail/index.ts
Page({

    /**
     * 页面的初始数据
     */
    data: {
        detailData: {
            images: []
        }
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(e: { id: string }) {
        regionDetail(e.id).then((r: any) => {
            r = {
                ...r,
                content: resetHtml(r.content),
            };
            this.setData({ detailData: r })
        })
    },
    // 预览图片
    previewImage() {
        const sources: any = this.data.detailData.images.map((v: { path: string }) => {
            return {
                url: v.path
            }
        });
        wx.previewMedia({
            sources
        })
    },
})